package edu.uniquindio.prmaven.proyectofinal;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;

import edu.uniquindio.prmaven.constants.ConfigurationConstants;
import edu.uniquindio.prmaven.constants.DataProvidersConstants;
import edu.uniquindio.prmaven.dataprovider.DataProviderArguments;
import edu.uniquindio.prmaven.general.TestCore;

public class ErrorDiligenciamiento extends TestCore {

	@Test()
	/**
	dataProviderClass = edu.uniquindio.prmaven.dataprovider.DataProviderFactory.class, 
	dataProvider = ConfigurationConstants.DP_FACTORY
	@DataProviderArguments(ConfigurationConstants.ESCENARIO
			+ ConfigurationConstants.EQUALS + DataProvidersConstants.HOJA_1)
			**/
	
	public void testValidationFirsname() throws Exception {
		
		try{
			
		selenium.open("/showcase/");
		
		//selenium.click("css=span.MainLinkText"); Selecciona menu Ajax Core
		WebElement menuAjax=driver.findElement(By.cssSelector("span.MainLinkText"));
		menuAjax.click();
						
		//selenium.click("link=• Validation"); xpath .//*[@id='MENUSIDEindent']/div[2]/a[6] Selecciona submenu Validation
		WebElement botonValidation=driver.findElement(By.xpath("//*[@id='MENUSIDEindent']/div[2]/a[6]"));
		botonValidation.click();
						
		selenium.waitForPageToLoad("30000");
		
		//selenium.type("id=j_idt87:firstname", "Ana Sofia"); Ingresa Cadena en campo Firstname
		WebElement cadena=driver.findElement(By.id("j_idt87:firstname"));
		cadena.sendKeys("Ana Sofia");
		
		//selenium.click("id=j_idt87:j_idt92"); click en guardar
		WebElement botonGuardar=driver.findElement(By.id("j_idt87:j_idt92"));
		botonGuardar.click();
		
		Assert.assertEquals(selenium.getText("css=span.ui-messages-error-summary"), 
				"Lastname: Validation Error: Value is required.");

		
		}catch(AssertionError e){
			System.out.println("no se encontro texto");
		}finally{
			
		}
	}

}
